package the.one.weather.util;

//  ┏┓　　　┏┓
//┏┛┻━━━┛┻┓
//┃　　　　　　　┃
//┃　　　━　　　┃
//┃　┳┛　┗┳　┃
//┃　　　　　　　┃
//┃　　　┻　　　┃
//┃　　　　　　　┃
//┗━┓　　　┏━┛
//    ┃　　　┃                  神兽保佑
//    ┃　　　┃                  永无BUG！
//    ┃　　　┗━━━┓
//    ┃　　　　　　　┣┓
//    ┃　　　　　　　┏┛
//    ┗┓┓┏━┳┓┏┛
//      ┃┫┫　┃┫┫
//      ┗┻┛　┗┻┛

import android.text.TextUtils;

import the.one.weather.R;

/**
 * @author The one
 * @date 2019/5/8 0008
 * @describe TODO
 * @email 625805189@qq.com
 * @remark
 */
public class WeatherUtil {

    /**
     * 根据天气得到对应的图片
     * @param weather
     * @return
     */
    public static int parseWeatherImage(String weather){
        if(TextUtils.isEmpty(weather))
            return R.drawable.ic_week_na;
        if(weather.contains("阴"))
            return R.drawable.ic_week_overcast;
        if(weather.contains("雷"))
            return R.drawable.ic_week_thunder_rain;

        if(weather.contains("雨")){
            if(weather.contains("中"))
                return R.drawable.ic_week_moderate_rain;
            if(weather.contains("暴")||weather.contains("大"))
                return R.drawable.ic_week_heavy_rain;
            if(weather.contains("雪"))
                return R.drawable.ic_week_sleet;
            if(weather.contains("冰雹"))
                return R.drawable.ic_week_rain_and_hail;
            return R.drawable.ic_week_light_rain;
        }
        if(weather.contains("冰雹"))
            return R.drawable.ic_week_hail;
        if(weather.contains("晴"))
            return R.drawable.ic_week_sun;
        if(weather.contains("云"))
            return R.drawable.ic_week_cloudy;
        if(weather.contains("雪")){
            if(weather.contains("小"))
                return R.drawable.ic_week_light_snow;
            if(weather.contains("中"))
                return R.drawable.ic_week_moderate_snow;
            if(weather.contains("风"))
                return R.drawable.ic_week_blizzard;
            if(weather.contains("暴")||weather.contains("大"))
                return R.drawable.ic_week_moderate_snow;
        }
        if(weather.contains("雾"))
            return R.drawable.ic_week_fog;
        if(weather.contains("霾"))
            return R.drawable.ic_week_haze;
        if(weather.contains("沙"))
            return R.drawable.ic_week_dust;

        return R.drawable.ic_week_na;
    }

    /**
     * 对天气进行转换，一律取前面的
     * @param weather
     * @return
     */
    public static String parseWeather(String weather){
        if(weather.contains("转"))
            return weather.substring(0,weather.indexOf("转"));
        return weather;
    }

    /**
     *
     * @param index
     * @return
     */
    public static int parseIndex(String index){
        if(index.contains("衣"))
            return R.drawable.ic_clothes_index;
        if(index.contains("车"))
            return R.drawable.ic_wash;
        if(index.contains("感冒"))
            return R.drawable.ic_cold_index;
        if(index.contains("运动"))
            return R.drawable.ic_support_index;
        if(index.contains("紫外线"))
            return R.drawable.ic_sun_index;
        else
            return R.drawable.ic_clothes_index;
    }

    /**
     * 根据天气转换成对应的天气视频
     * @param weather
     * @return
     */
    public static int parseWeatherVideo(String weather){
        if(weather.contains("晴"))
            return R.raw.sun;
        if(weather.contains("云"))
            return R.raw.cloud_02;
        if(weather.contains("雨")){
            if(weather.contains("雷"))
                return R.raw.thundershowers;
            return R.raw.rain;
        }
        if(weather.contains("雾"))
            return R.raw.fog;
        if(weather.contains("沙"))
            return R.raw.sand;
        if(weather.contains("雪"))
            return R.raw.snow;
        if(weather.contains("霾"))
            return R.raw.haze;
        return R.raw.cloud_02;
    }

    /**
     * 根据天气转换成对应的天气字体颜色
     * @param weather
     * @return
     */
    public static int parseWeatherColor(String weather){
        if(weather.contains("晴"))
            return R.color.sun;
        if(weather.contains("云") || weather.contains("阴"))
            return R.color.cloud;
        return R.color.rain;
    }


}
